﻿/*
 * Сделано в SharpDevelop.
 * Пользователь: aleva3
 * Дата: 11.04.2014
 * Время: 10:35
 */
using System;

namespace Froude_and_Wt_calculation
{
	
	public enum Velocity
	{
		MetersPerSecond = 1,
		Knot = 2,
		KilomesterPerHour = 3
	}
	
	/// <summary>
	/// Description of FroudeCalculator.
	/// </summary>
	public class FroudeCalculator
	{
		const double g = 9.81;
		
		private double speedTranslator = 1;
		
		private double u;
		public double U { 
			get { return u; }
			set { u = value * speedTranslator; }
		}
		
		public double L { get; set; }
		
		public double Value { get; private set; }
		
		public FroudeCalculator()
		{
		}
		
		public FroudeCalculator(double u, double l, Velocity element)
		{
			SetSpeedTranslator( element );
			U = u;
			L = l;
			Value = U/Math.Sqrt( g * L );
		}
		
		public void SetSpeedTranslator( Velocity element )
		{
			switch( element )
			{
				case Velocity.MetersPerSecond:
					speedTranslator = 1;
					break;
				case Velocity.Knot:
					speedTranslator = 1.852 / 3.6;
					break;
				case Velocity.KilomesterPerHour:
					speedTranslator = 1 / 3.6;
					break;
			}
		}
	}
}
